package com.migration.model.migration.scripts;

import com.migration.model.migration.AbstractMigrationScript;

/**
 * 风险矩阵-可能性表(risk_matrix_likelihood)迁移脚本
 */
public class A016_RiskMatrixLikelihoodMigrationScript extends AbstractMigrationScript {

    /**
     * 构造函数，初始化迁移配置
     */
    public A016_RiskMatrixLikelihoodMigrationScript() {
        super(
            "risk_matrix_likelihood",
            "风险矩阵-可能性数据迁移",
            "ra_possible_grade",
            "risk_matrix_likelihood",
            16
        );
    }

    /**
     * 生成迁移数据的SQL
     *
     * @return 迁移数据的SQL
     */
    @Override
    protected String generateMigrationSql() {
        return "INSERT INTO risk_matrix_likelihood (\n" +
                "    id,\n" +
                "    tenant_id,\n" +
                "    likelihood_level,\n" +
                "    frequency_min,\n" +
                "    frequency_max,\n" +
                "    frequency_value,\n" +
                "    frequency_desc,\n" +
                "    likelihood_desc,\n" +
                "    sort_num,\n" +
                "    create_time,\n" +
                "    update_time,\n" +
                "    create_by,\n" +
                "    update_by,\n" +
                "    is_del\n" +
                ")\n" +
                "SELECT\n" +
                "    id,\n" +
                "    1 as tenant_id,\n" +
                "    grade,\n" +
                "    CAST(min_frequency AS CHAR),\n" +
                "    CAST(max_frequency AS CHAR),\n" +
                "    occur_frequency,\n" +
                "    frequency_desc,\n" +
                "    possible_msg,\n" +
                "    index_sort,\n" +
                "    DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s'),\n" +
                "    DATE_FORMAT(update_time, '%Y-%m-%d %H:%i:%s'),\n" +
                "    1,\n" +
                "    1,\n" +
                "    is_del\n" +
                "FROM risk_lunnan_test.ra_possible_grade\n" +
                "where tenant_id = 24;";
    }

}
